package com.study_security.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.study_security.entity.Project;
import com.study_security.mapper.ProjectMapper;
import com.study_security.service.AuditService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AuditServiceImpl extends ServiceImpl<ProjectMapper, Project> implements AuditService {

    @Autowired
    private ProjectMapper projectMapper;
    @Override
    public List<Project> findPendingByName(String name) {
        return projectMapper.findPendingByName(name);
    }

    @Override
    public List<Project> findApprovedByName(String name) {
        return projectMapper.findApprovedByName(name);
    }

    @Override
    public List<Project> findOngoingByName(String name) {
        return projectMapper.findOngoingdByName(name);
    }

    @Override
    public List<Project> findPending() {
        return projectMapper.findPending();
    }

    @Override
    public List<Project> findApproved() {
        return projectMapper.findApproved();
    }

    @Override
    public List<Project> findOngoing() {
        return projectMapper.findOngoing();
    }

    @Override
    public boolean updateProjectStatus(Long projectId, boolean isApproved) {

        String status = isApproved ? "已过审" : "未过审";
        System.out.println("1111111111111111111111111111111111111111111111111111111111");
        System.out.println(projectId);
        System.out.println(status);
        return projectMapper.updateProjectStatus(projectId, status) > 0;
    }
}
